﻿@using GigaSite.Domain.Entities
@model GigaSite.Domain.Entities.Category
@{
    string categoryUrlFormat = ViewBag.categoryUrlFormat;
    Func<Category, int> itemsCountSelector = ViewBag.categoryItemsCountSelector;
}


<div class="dynamicCategory" data-id="@Model.Id">
    <table width="100%">
        <tbody>
            <tr valign="middle">
                <td>
                    <div class="categoryTitle">
                        <a href="@String.Format(categoryUrlFormat,Model.Id)">@Model.DisplayName</a>
                    </div>
                </td>
                <td>
                    <div class="expandCollapseButton categoriesDetailsToggle">
        
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
    <table class="categoryStatistic" style="display: none">
        <tbody>
            <tr>
                <td align="right">
                    @(itemsCountSelector != null ? itemsCountSelector(Model).ToString() : "")
                </td> 
                <td>
                    предложений в разделе
                </td>
            </tr>  
            @if (Model.HasChildCategories)
            {
                <tr>
                    <td align="right">
                        @Model.ChildCategoriesCount
                    </td>
                    <td>
                        категорий
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>